import { NodeStatus } from "../../../common/Enum";
import BTDecorator from "../../Base/BTDecorator";
/** 反转节点，返回子节点的结果相反的结果 */
export default class DecoratorInverter extends BTDecorator {
    canExecute(): boolean {
        return this.status === NodeStatus.Running || this.status === NodeStatus.Inactive
    }
    onChildExecuted(status: NodeStatus): void {
        this.status = status
    }

    decorate(status: NodeStatus): NodeStatus {

        switch (status) {
            case NodeStatus.Failure:
                return NodeStatus.Success

            case NodeStatus.Success:
                return NodeStatus.Failure

            default:
                return this.status
        }

    }
}